package com.jiazhong.spring.ioc.work.work02;

// 打印机
public class Printer {

    private Paper paper;
    private Ink ink;

    public Printer() {
    }

    public Printer(Paper paper, Ink ink) {
        this.paper = paper;
        this.ink = ink;
    }

    public void print(String message) {
        System.out.println("使用了" + ink.color() + "进行打印");
        for (int i = 0; i < message.length(); i++) {
            System.out.print(message.charAt(i));
            if ((i + 1) % paper.size() == 0) {
                System.out.println();
            }
        }
    }
}
